#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''PyQt5, Vtk, CGAL-swig-bindings

历史:
    2018-11-30 姚彧 创建
'''

import os
import sys
from PyQt5.QtWidgets import QApplication
from events.EventCenter import (EventContext, EventDispatcher)
from app.app_config import AppConfig
from app.user_config import UserConfig
from ui.yPaneOutput import yPaneOutput
from ui.yMainWindow import yMainWindow
from project.manager import ProjectManager

def app_init():
    AppConfig()
    UserConfig()

def my_log(context:EventContext, *args, **kwargs):
    print((context, args, kwargs))

event_handlers = (yMainWindow,
                  yPaneOutput,
                  ProjectManager,
                  )

def main():
    app_init()
    EventDispatcher().register('*', my_log)
    app = QApplication(sys.argv)
    for handler in event_handlers:
        if hasattr(handler, 'register_events'):
            getattr(handler, 'register_events')()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()